<div class="alert alert-success alert-dismissable">
    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
    <%- message %>

</div>
<div class="panel panel-info">
<div class="panel-heading"><h4 class="panel-title">用户管理</h4></div>
<form action="/users/upsert/<%=_id?_id:'nil'%>" method="post" class="form-horizontal" id="uform" role="form">
    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">用户名</label>

        <div class="col-sm-10">
            <input type="text" class="form-control" name="name" placeholder="Email">
        </div>
    </div>
    <div class="form-group">
        <label for="inputPassword3" class="col-sm-2 control-label">密码</label>

        <div class="col-sm-10">
            <input type="password" class="form-control" name="password" placeholder="Password">
        </div>
    </div>
    <div class="form-group">
        <label for="password2" class="col-sm-2 control-label">重复密码</label>

        <div class="col-sm-10">
            <input type="password" class="form-control" name="password2" placeholder="Password">
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">所属组</label>
        <div class="col-sm-10">
        <table class="table table-hover table-striped  table-condensed">
            <caption>请选择用户组,请注意不同组具有不同操作权限,多选组权限会合并</caption>
             <tbody id="groups"> </tbody>
        </table>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-default">保存</button>
        </div>
    </div>

</form>
</div>
 <script>
     var beans = <%-beans%>;

     $(function(){

         $.getJSON('/groups/jsonall',function(data){

             var tbody = $("#groups");
             tbody.empty();
             var tr = null;
             for(var i=0;i<data.length;i++){
                 if(i%5==0){
                     tr = $("<tr></tr>");
                     tbody.append(tr);
                 }
                 var chk=$("<input type='checkbox' >");
                 chk.attr("name","groups["+i+"]");
                 chk.val(data[i]._id);
                 var chklabel = $("<label></label>").append(chk).append(data[i].name);
                 var td = $("<td></td>").append(chklabel);
                 tr.append(td);

             }

             $("form#uform").helpform({'beans':beans});

         });


     });
 </script>

